# coding=utf-8
from selenium.webdriver.support import expected_conditions as EC

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time

from selenium.webdriver.support.wait import WebDriverWait

'''
browser = webdriver.Firefox()
browser.get('http://www.baidu.com/')
'''

# Login yanxiu
driver = webdriver.Firefox()
#driver.get("http://www.zgjiaoyan.com/")
  #use keyboard return to login
driver.get("http://main.zgjiaoyan.com/hddy/create_ask?biz_id=1203_720176_720175")
#driver.implicitly_wait(10)
time.sleep(4)
elem_user = driver.find_element_by_name("username")
elem_user.clear
elem_user.send_keys("18333646084")
elem_pwd = driver.find_element_by_name("password")
elem_pwd.clear
elem_pwd.send_keys("123456")
time.sleep(2)
elem_pwd.send_keys(Keys.RETURN)
time.sleep(3)
driver.find_element_by_xpath("html/body/div[4]/div/div[2]/div[4]").click()
if WebDriverWait(driver,20,0.5).until(EC.text_to_be_present_in_element(By.CSS_SELECTOR,"#toast"),u'不存在'):
    print('test success')

#driver.close()
#driver.quit()  #kill driver server